package com.myidis.controller;

import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.myidis.entity.Quota;
import com.myidis.entity.QuotaData;
import com.myidis.servlet.QuotaQueryServlet;
import jxl.write.WriteException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.myidis.entity.QuotaList;
import com.myidis.request.SearchReq;
//import com.myidis.upload_download.Download;
//
//import jxl.write.WriteException;
//import jxl.write.biff.RowsExceededException;
//
//import java.io.*;



@Controller
@RequestMapping("/qq")
public class QuotaQueryController {
	@Autowired
	private QuotaQueryServlet quotaQueryServlet;

//	@ResponseBody
//	@RequestMapping("/list")
//	public List<QuotaList> selectQuotaName(@RequestBody SearchReq sea){
//		return monthSelectPageServlet.selectQuotaName(sea);
//	}

	@ResponseBody
	@RequestMapping("/searchByTime")
	public  ArrayList<QuotaData> bytime(@RequestBody SearchReq sea){
		return quotaQueryServlet.bytime(sea);
	}

	@ResponseBody
	@RequestMapping("/firstSearch")
	public ArrayList<QuotaList> sea1(@RequestBody SearchReq sea){
		return quotaQueryServlet.search1(sea);
	}

	@ResponseBody
	@RequestMapping("/secondSearch")
	public ArrayList<QuotaList> sea2(@RequestBody SearchReq sea){
		return quotaQueryServlet.search2(sea);
	}
	
	@ResponseBody
	@RequestMapping("/return")
	public ArrayList<QuotaData> ret(@RequestBody SearchReq sea){
		return quotaQueryServlet.ret(sea);
	}
	
	@ResponseBody
	@RequestMapping("/change")
	public int cha(@RequestBody QuotaData cha) {
		return quotaQueryServlet.change(cha);
	}
	
	@RequestMapping("/upload")
	  public  @ResponseBody String upload(@RequestParam("file") MultipartFile file, @RequestBody  Quota quota) throws Exception {
		return quotaQueryServlet.upload(file,quota);
	}

	@RequestMapping("/export")
    public int downloadFile(@RequestBody SearchReq sea,
    		HttpServletResponse response) throws WriteException, IOException, SQLException {
		return quotaQueryServlet.download(sea,response);
	}


}
